def hIndex(citations):
    """
    :type citations: List[int]
    :rtype: int
    """
    # if len(citations)==1:
    #     return 1
    temp = citations[:]
    length = 0
    if len(citations) % 2 == 0:
        length = len(citations) // 2
    else:
        length = len(citations) // 2 + 1
    while True:
        if temp == []:
            return len(citations)
        max_citations = max(temp)
        num = 0
        for i in range(0, len(citations)):
            if citations[i] >= max_citations:
                num = num + 1
        if num >= length:
            return num
        temp.remove(max_citations)

if __name__ == "__main__":
    citations = [1, 3, 1]
    print(hIndex(citations))